package it.storm.solution;

/**
 * 1486. 数组异或操作
 * https://leetcode-cn.com/problems/xor-operation-in-an-array/
 */
public class Solutions_1486 {
    public static void main(String[] args) {
//        int n = 5, start = 0;  // output: 8
//        int n = 4, start = 3;  // output: 8
//        int n = 1, start = 7;  // output: 7
        int n = 10, start = 5;  // output: 2

        int result = xorOperation(n, start);
        System.out.println(result);
    }

    public static int xorOperation(int n, int start) {
        int res = 0;
        for (int i = 0; i < n; i++) {
            res ^= start + (2 * i);
        }
        return res;
    }
}
